﻿using System;
using System.IO;

namespace _10.ExtractXML
{
    class ExtractXML
    {
        static void Main()
        {
            string inputFile = "XML.txt";
            string outputFile = "XMLextract.txt";
            using (StreamReader reader = new StreamReader(inputFile))
            using (StreamWriter writer = new StreamWriter(outputFile))
            {
                char c = new char();
                while (reader.Peek() >= 0)
                {
                    c = (char)reader.Read();
                    if (c == '>')
                    {
                        string text = "";
                        c = (char)reader.Read();
                        while (c != '<' && reader.Peek() >= 0)
                        {
                            text += c;
                            c = (char)reader.Read();
                        }
                        if (text.Length > 0)
                        {
                            writer.WriteLine(text);
                        }
                    }
                }
            }
        }
    }
}
